home *** CD-ROM | disk | FTP | other *** search
/ Get a Grip Tennis by Wilson / Get a Grip Tennis by Wilson.iso / pc / wilson.dxr / Internal_25_scroll bar TEXT (thumb).ls < prev    next >
Encoding:
Text File  |  2003-08-12  |  2.8 KB  |  101 lines

  1. property pMySprite, pTop, pBottom, pFieldMem, pFieldSpriteNum, pScrollFactor, pThumbMargin, pStartingLoc, pVisFlag
  2.  
  3. on getPropertyDescriptionList me
  4.   mylist = []
  5.   repeat with y = 1 to the number of castLibs
  6.     repeat with x = 1 to the number of castMembers of castLib y
  7.       if member(x, y).type = #text then
  8.         mylist.add(member(x, y).name)
  9.         next repeat
  10.       end if
  11.       if member(x, y).type = #field then
  12.         mylist.add(member(x, y).name)
  13.       end if
  14.     end repeat
  15.   end repeat
  16.   pdlist = [:]
  17.   addProp(pdlist, #pTop, [#comment: "Top limit for scroll thumb:", #format: #integer, #default: 0])
  18.   addProp(pdlist, #pBottom, [#comment: "Bottom limit:", #format: #integer, #default: 0])
  19.   addProp(pdlist, #pFieldMem, [#comment: "Text Member Name:", #format: #member, #default: EMPTY, #range: mylist])
  20.   addProp(pdlist, #pFieldSpriteNum, [#comment: "Text Member Sprite Number:", #format: #integer, #default: 1, #range: [#max: 120, #min: 1]])
  21.   return pdlist
  22. end
  23.  
  24. on beginSprite me
  25.   pMySprite = me.spriteNum
  26.   pStartingLoc = sprite(pMySprite).loc
  27.   if member(pFieldMem).height < sprite(pFieldSpriteNum).height then
  28.     sendAllSprites(#hideScrollBar)
  29.     member(pFieldMem).scrollTop = 1
  30.   else
  31.     sendAllSprites(#showScrollBar)
  32.   end if
  33. end
  34.  
  35. on mouseDown me
  36.   repeat while the stillDown
  37.     slideScroll(me)
  38.   end repeat
  39. end
  40.  
  41. on arrowScroll me, scrollincr
  42.   newV = sprite(pMySprite).locV + scrollincr
  43.   if (newV < (pTop + pThumbMargin)) and (scrollincr < 0) then
  44.     newV = pTop
  45.   else
  46.     if (newV > (pBottom - pThumbMargin)) and (scrollincr > 0) then
  47.       newV = pBottom
  48.     end if
  49.   end if
  50.   sprite(pMySprite).locV = newV
  51.   updateStage()
  52.   scroll(me)
  53. end
  54.  
  55. on scroll me
  56.   thumbPos = sprite(pMySprite).locV - pTop
  57.   member(pFieldMem).scrollTop = thumbPos * pScrollFactor
  58.   updateStage()
  59. end
  60.  
  61. on slideScroll me
  62.   if (the mouseV > pTop) and (the mouseV < pBottom) then
  63.     sprite(pMySprite).locV = the mouseV
  64.   else
  65.     if the mouseV < (pTop + pThumbMargin) then
  66.       sprite(pMySprite).locV = pTop
  67.     else
  68.       if the mouseV > (pBottom + pThumbMargin) then
  69.         sprite(pMySprite).locV = pBottom
  70.       end if
  71.     end if
  72.   end if
  73.   updateStage()
  74.   scroll(me)
  75. end
  76.  
  77. on hideScrollBar me
  78.   pVisFlag = 0
  79.   sprite(pMySprite).loc = point(-1000, -1000)
  80. end
  81.  
  82. on showScrollBar me
  83.   pVisFlag = 1
  84.   scrollRange = member(pFieldMem).height - sprite(pFieldSpriteNum).height
  85.   thumbrange = (pBottom - pTop) * 1.0
  86.   pScrollFactor = scrollRange / thumbrange
  87.   pThumbMargin = sprite(pMySprite).height / 2
  88.   member(pFieldMem).scrollTop = 1
  89.   sprite(pMySprite).loc = pStartingLoc
  90. end
  91.  
  92. on exitFrame me
  93.   if (member(pFieldMem).height > sprite(pFieldSpriteNum).height) and (pVisFlag = 0) then
  94.     sendAllSprites(#showScrollBar)
  95.   else
  96.     if (member(pFieldMem).height < sprite(pFieldSpriteNum).height) and (pVisFlag = 1) then
  97.       sendAllSprites(#hideScrollBar)
  98.     end if
  99.   end if
  100. end
  101.